package com.sportizz.sport;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TimeZone;
import java.util.Timer;
import java.util.TimerTask;

import org.json.JSONArray;
import org.json.JSONObject;

import com.blundell.test.util.Developer_key;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubeStandalonePlayer;
import com.sportizz.model.ImageLoader;
import com.sportizz.model.custom_marquee_text;
import com.sportizz.model.new_ifollow_player;
import com.sportizz.sport.R.color;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.provider.CalendarContract;
import android.provider.CalendarContract.Events;
import android.provider.CalendarContract.Instances;
import android.provider.CalendarContract.Reminders;
import android.text.InputType;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout.LayoutParams;

public class new_upcoming_adapter extends BaseAdapter {

	private static final int REQ_START_STANDALONE_PLAYER = 1;
	private static final int REQ_RESOLVE_SERVICE_MISSING = 2;

	Context con;
	Activity act_con;
	List<new_ifollow_player> new_upcoming_match;
	String champ_sp, player_sp, player_list, champ_list;
	DatabaseAdapter datadapter;
	ImageLoader imgLoader;
	public ProgressDialog pd;
	String device_id;

	 Typeface sport_font ;
	 
	public new_upcoming_adapter(Context _context,
			List<new_ifollow_player> list, String champ_list_final,
			String champ_sport_final, String player_list_final,
			String player_sport_final) {

		this.con = _context;
		this.act_con = (Activity) _context;
		this.new_upcoming_match = list;
		this.champ_sp = champ_sport_final;
		this.player_sp = player_sport_final;
		this.player_list = player_list_final;
		this.champ_list = champ_list_final;

		datadapter = new DatabaseAdapter(con);
		imgLoader = new ImageLoader(con.getApplicationContext());
		StartActivity sa = new StartActivity();
		device_id = sa.GetDeviceID(act_con);
		 sport_font = Typeface.createFromAsset(con.getAssets(),
					"hel57.ttf");
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return new_upcoming_match.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@SuppressLint("NewApi")
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {

		final LayoutInflater inflater = (LayoutInflater) con
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		final ViewHolder holder;

//		final View view = convertView;
		if (convertView == null) {

			convertView = inflater.inflate(R.layout.new_upcoming, parent, false);
			holder = new ViewHolder();

			assert convertView != null;

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
			// view = convertView;
		}

//		new Thread(new Runnable() {
//
//			@Override
//			public void run() {
//
//				act_con.runOnUiThread(new Runnable() {
//
//					@Override
//					public void run() {
			
						holder.horizontal_layout_upcoming = (LinearLayout) convertView
								.findViewById(R.id.horizontal_layout_upcoming);

						holder.txt_champ_name_upcoming = (TextView) convertView
								.findViewById(R.id.txt_champ_name_upcoming);
						holder.txt_sport_name_upcoming = (TextView) convertView
								.findViewById(R.id.txt_sport_name_upcoming);

						holder.new_layout_gap = (LinearLayout) convertView
								.findViewById(R.id.new_layout_gap);
						
			String new_ifollow = new_upcoming_match.get(position)
					.getNew_match_data();

			Log.d("suraj_", "Suraj SHinde = " + new_ifollow);

			final int row_count = new_upcoming_match.get(position).getnew_count();
			// final int row_count = new_follow_match.get(posi tion).getnew_count();

			final String is_team = new_upcoming_match.get(position).getteam_sport();

			Log.v("suraj_", "Suraj SHinde is_team = " + is_team);

			// Log.v("suraj_",
			// "Suraj SHinde Champ = "+new_follow_match.get(position).getNew_champ_data());
			Log.d("suraj_", "Suraj SHinde = " + row_count);

			final String champ_details = new_upcoming_match.get(position)
					.getNew_champ_data();

			

			if (is_team.equals("Y") || is_team.equals("N")) {
				final String[] every_row_matchs = new_ifollow.split(";");

//				new Thread(new Runnable() {
//	
//					@Override
//					public void run() {
//	
//						act_con.runOnUiThread(new Runnable() {
//	
//							@Override
//							public void run() {
								int pos = 7;

								Log.w("suraj_", "" + every_row_matchs[1]);

								final String sport_code = every_row_matchs[3];
								final String sport_type = every_row_matchs[4];

								// holder.progress_ifollow.setVisibility(View.GONE);
								holder.horizontal_layout_upcoming.removeAllViews();

								// txt_champ_name_ifollow.setVisibility(View.VISIBLE);
								// txt_sport_name_ifollow.setVisibility(View.VISIBLE);

								int rc=0;
								
								if(row_count >=  10)
								{
									rc=10;
								}
								else
								{
									rc=row_count;
								}
								
								for (int i = 0; i < rc; i++) {

									String[] match = every_row_matchs[pos]
											.split(",");
									String[] match_player = match[1].split(":");

									final String player_1 = match_player[1];
									final String player1_country = match_player[2];
									String player1_club = match_player[3];

									final String player_2 = match_player[5];
									final String player2_country = match_player[6];
									String player2_club = match_player[7];

									final String player_3 = match_player[9];
									final String player3_country = match_player[10];
									final String player_4 = match_player[12];
									final String player4_country = match_player[13];

									String p1_code = match_player[0];
									String p2_code = match_player[4];
									String p3_code = match_player[8];
									String p4_code = match_player[11];

									final String tick_url = every_row_matchs[pos + 2];

									String date_string = every_row_matchs[pos + 1];

									final String[] day_date = date_string
											.split(",");

									String[] channel_details = every_row_matchs[pos + 3]
											.split(",");

									String[] channels = channel_details[1]
											.split(":");

									String chan1 = channels[0];
									String chan2 = channels[1];
									String chan3 = channels[2];

									View additionView = inflater.inflate(
											R.layout.new_hori_player_row, null,
											false);

									final RelativeLayout linear = (RelativeLayout) additionView
											.findViewById(R.id.new_hori_player_layout);

									final ImageView new_img_p1 = (ImageView) additionView
											.findViewById(R.id.new_image_p1_hor);
									final ImageView new_img_p2 = (ImageView) additionView
											.findViewById(R.id.new_image_p2_hor);

									additionView.findViewById(R.id.tableRow3)
											.setVisibility(View.VISIBLE);

									Button btn_ticket = (Button) additionView
											.findViewById(R.id.ticket_player_hor);
									Button btn_cal_add = (Button) additionView
											.findViewById(R.id.new_btn_player_addcal_hor);

									TextView game = (TextView) additionView.findViewById(R.id.new_txt_game_hor);
									TextView match_tx = (TextView) additionView.findViewById(R.id.new_txt_match_hor);
									
									game.setTypeface(sport_font);
									match_tx.setTypeface(sport_font);
									
									String url = null;
									// ImageLoader imloader=new
									// ImageLoader(con.getApplicationContext());

									// /////

									if (i == row_count - 1) {
										additionView.findViewById(R.id.gap)
												.setVisibility(View.INVISIBLE);
									}

									InputStream iss = null;
									try {
										iss = con
												.getResources()
												.getAssets()
												.open("new_sports/" + sport_code
														+ ".png");
									} catch (IOException e1) {
										e1.printStackTrace();
										try {
											iss = act_con.getResources().getAssets()
													.open("new_sports/GAM.png");
										} catch (IOException e) {
											e.printStackTrace();
										}
									}
									Bitmap result1 = BitmapFactory
											.decodeStream(iss);

									Bitmap output = null;
									Canvas canvas;
									float roundPx;

									output = Bitmap.createBitmap(
											result1.getWidth(),
											result1.getHeight(),
											Bitmap.Config.ARGB_8888);
									canvas = new Canvas(output);

									Paint paint = new Paint();
									Rect rect = new Rect(0, 0, result1.getWidth(),
											result1.getHeight());
									RectF rectF = new RectF(rect);
									roundPx = 8f;

									paint.setAntiAlias(true);
									canvas.drawARGB(0, 0, 0, 0);
									paint.setColor(0xff424242);
									canvas.drawRoundRect(rectF, roundPx, roundPx,
											paint);
									paint.setXfermode(new PorterDuffXfermode(
											Mode.SRC_IN));
									canvas.drawBitmap(result1, rect, rect, paint);

									new_img_p1.setImageBitmap(output);
									// new_img_p1.setScaleType(ScaleType.FIT_CENTER);

									new_img_p2.setImageBitmap(output);
									// new_img_p2.setScaleType(ScaleType.FIT_CENTER);

									// //

									String game_txt = "";

									if (sport_type.equalsIgnoreCase("N")) {

										String[] game_match = every_row_matchs[pos + 4].split(":");

										game_txt = game_match[0];
										
										Log.w("suraj","game_txtu  = "+game_txt + " match_txu = "+game_match[1]);
										
										
										if(game_txt.equals(" ") || game_txt == null || game_txt.contains("null"))
										{
											game.setText("");
										}else
										{
											game.setText(game_txt);
										}
										
										if(game_match[1].equals(" ") || game_match[1] == null||game_match[1].contains("null"))
										{
											match_tx.setText("");
										}else
										{
											match_tx.setText(game_match[1]);
										}

										
										if (game_txt.contains("Doubles")) {
											additionView.findViewById(
													R.id.tableRow3).setVisibility(
													View.VISIBLE);
											Bitmap result = null;
											InputStream is = null;
											try {
												is = con.getResources().getAssets().open("new_sports/"
																+ sport_code
																+ ".png");

												result = BitmapFactory
														.decodeStream(is);

											} catch (Exception e) {
												try {
													is = con.getResources().getAssets().open("new_sports/GAM.png");

													result = BitmapFactory
															.decodeStream(is);
												} catch (IOException e1) {
													e1.printStackTrace();
												}
											}

											Bitmap output1 = null;
											Canvas canvas1;
											// float roundPx1;

											output1 = Bitmap.createBitmap(
													result.getWidth(),
													result.getHeight(),
													Bitmap.Config.ARGB_8888);
											canvas = new Canvas(output1);

											Paint paint1 = new Paint();
											Rect rect1 = new Rect(0, 0, result
													.getWidth(), result.getHeight());
											RectF rectF1 = new RectF(rect1);
											roundPx = 8f;

											paint1.setAntiAlias(true);
											canvas.drawARGB(0, 0, 0, 0);
											paint1.setColor(0xff424242);
											canvas.drawRoundRect(rectF1, roundPx,
													roundPx, paint1);
											paint1.setXfermode(new PorterDuffXfermode(
													Mode.SRC_IN));
											canvas.drawBitmap(result, rect1, rect1,
													paint1);

											new_img_p1.setImageBitmap(output1);
											// new_img_p1.setScaleType(ScaleType.FIT_CENTER);

											new_img_p2.setImageBitmap(output1);
											// new_img_p2.setScaleType(ScaleType.FIT_CENTER);

										} else {
											additionView.findViewById(
													R.id.tableRow3).setVisibility(
													View.GONE);

											

											// imgLoader.DisplayImage(url2,
											// loader_row, new_img_p2);

											// new imageTask(new_img_p2, sport_code)
											// .execute(url);
											AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

												@Override
												protected void onPostExecute(
														Void result) {
													super.onPostExecute(result);
												
												}

												@Override
												protected void onPreExecute() {
													
													super.onPreExecute();
												}

												@Override
												protected Void doInBackground(
														Void... params) {
													
													act_con.runOnUiThread(new Runnable() {
														
														@Override
													public void run() {
													
													String p1_url = StartActivity.get_img_location
															+ "phone/country/"
															+ player1_country + ".png";

													// new imageTask(new_img_p1, sport_code)
													// .execute(url);

													String p2_url = StartActivity.get_img_location
															+ "phone/country/"
															+ player2_country + ".png";
													
													
															int loader = getImgLoader(sport_code);

															imgLoader.DisplayImage(
																	p1_url, loader,
																	new_img_p1);

															imgLoader.DisplayImage(
																	p2_url, loader,
																	new_img_p2);
																	
																							
														}
													});
															return null;
												}
											};
											wait.execute();
										}
									} else if (sport_type.equalsIgnoreCase("Y")) {
										// game_txt = every_row_matchs[pos + 4];

										String[] game_match = every_row_matchs[pos + 4].split(":");

										game_txt = game_match[0];
										
										Log.w("suraj","game_txtu  = "+game_txt + " match_txu = "+game_match[1]);
										
										if(game_txt.equals("") || game_txt == null || game_txt.contains("null"))
										{
											game.setText("");
										}else
										{
											game.setText(game_txt);
										}
										
										if(game_match[1].equals("") || game_match[1] == null|| game_match[1].contains("null"))
										{
											match_tx.setText("");
										}else
										{
											match_tx.setText(game_match[1]);
										}
										
										additionView.findViewById(R.id.tableRow3)
												.setVisibility(View.GONE);
										if (player1_club
												.equalsIgnoreCase(player1_country)) {

											final String p1_url = StartActivity.get_img_location
													+ "phone/country/"
													+ player1_country + ".png";

											// new imageTask(new_img_p1, sport_code)
											// .execute(url);
//											act_con.runOnUiThread(new Runnable() {
	//
//												@Override
//												public void run() {
//											new AsyncTask<Void,Void,Void>();
											AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

												@Override
												protected void onPostExecute(
														Void result) {
													super.onPostExecute(result);
												
												}

												@Override
												protected void onPreExecute() {
													
													super.onPreExecute();
												}

												@Override
												protected Void doInBackground(
														Void... params) {
													int loader = getImgLoader(sport_code);

													imgLoader.DisplayImage(p1_url,
															loader, new_img_p1);
													return null;
												}
											};
											wait.execute();
										} else {
											final String p1_url = StartActivity.get_img_location
													+ "phone/"
													+ sport_code
													+ "/"
													+ p1_code
													+ ".png";
											// new imageTask(new_img_p1, sport_code)
											// .execute(url);
											AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

												@Override
												protected void onPostExecute(
														Void result) {
													super.onPostExecute(result);

												}

												@Override
												protected void onPreExecute() {

													super.onPreExecute();
												}

												@Override
												protected Void doInBackground(
														Void... params) {
													int loader = getImgLoader(sport_code);

													imgLoader.DisplayImage(p1_url,
															loader, new_img_p1);
													return null;
												}
											};
											wait.execute();
										}

										if (player2_club
												.equalsIgnoreCase(player2_country)) {
											final String p2_url = StartActivity.get_img_location
													+ "phone/country/"
													+ player2_country + ".png";

											// new imageTask(new_img_p2, sport_code)
											// .execute(url);
											AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

												@Override
												protected void onPostExecute(
														Void result) {
													super.onPostExecute(result);

												}

												@Override
												protected void onPreExecute() {

													super.onPreExecute();
												}

												@Override
												protected Void doInBackground(
														Void... params) {
													int loader = getImgLoader(sport_code);

													imgLoader.DisplayImage(p2_url,
															loader, new_img_p2);
													return null;
												}
											};
											wait.execute();
										} else {

											final String p2_url = StartActivity.get_img_location
													+ "phone/"
													+ sport_code
													+ "/"
													+ p2_code
													+ ".png";

											// new imageTask(new_img_p2, sport_code)
											// .execute(url);
											AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

												@Override
												protected void onPostExecute(
														Void result) {
													super.onPostExecute(result);

												}

												@Override
												protected void onPreExecute() {

													super.onPreExecute();
												}

												@Override
												protected Void doInBackground(
														Void... params) {
													int loader = getImgLoader(sport_code);

													imgLoader.DisplayImage(p2_url,
															loader, new_img_p2);
													return null;
												}
											};
											wait.execute();
										}
									}

									TextView player1 = (TextView) additionView
											.findViewById(R.id.new_txt_player1_hor);
									player1.setSelected(true);
									player1.setText(player_1);
									player1.setTypeface(sport_font);

									TextView player2 = (TextView) additionView
											.findViewById(R.id.new_txt_player2_hor);
									player2.setSelected(true);
									player2.setText(player_2);
									player2.setTypeface(sport_font);

									TextView player3 = (TextView) additionView
											.findViewById(R.id.new_txt_player3_hor);
									player3.setText(player_3);
									player3.setSelected(true);
									player3.setTypeface(sport_font);

									TextView player4 = (TextView) additionView
											.findViewById(R.id.new_txt_player4_hor);
									player4.setText(player_4);
									player4.setSelected(true);
									player4.setTypeface(sport_font);

									TextView new_txt_pday_hor = (TextView) additionView
											.findViewById(R.id.new_txt_pday_hor);

									new_txt_pday_hor.setText(day_date[0]);
									new_txt_pday_hor.setTypeface(sport_font);
									
									TextView new_txt_pdate_hor = (TextView) additionView
											.findViewById(R.id.new_txt_pdate_hor);

									String[] ddate = day_date[1].split(" ");

									new_txt_pdate_hor.setText(ddate[0] + "\n"
											+ ddate[1] + " " + ddate[2]);
									new_txt_pdate_hor.setTypeface(sport_font);
									
									// new_txt_pdate_hor.setText(day_date[1]);

									additionView.findViewById(R.id.tableRow2)
											.setVisibility(View.VISIBLE);

									final Button new_btn_p_follow1_hor = (Button) additionView
											.findViewById(R.id.new_btn_p_follow1_hor);
									new_btn_p_follow1_hor.setTag(p1_code + ":"
											+ player_1 + ":" + every_row_matchs[2]
											+ ":" + every_row_matchs[4] + ":"
											+ player1_country + ":" + p3_code + ":"
											+ player_3 + ":" + player3_country
											+ ":" + sport_code + ":"
											+ every_row_matchs[1]);

									final Button new_btn_p_follow2_hor = (Button) additionView
											.findViewById(R.id.new_btn_p_follow2_hor);

									new_btn_p_follow2_hor.setTag(p2_code + ":"
											+ player_2 + ":" + every_row_matchs[2]
											+ ":" + every_row_matchs[4] + ":"
											+ player2_country + ":" + p4_code + ":"
											+ player_4 + ":" + player4_country
											+ ":" + sport_code + ":"
											+ every_row_matchs[1]);

									new_btn_p_follow1_hor.setTypeface(sport_font);
									new_btn_p_follow2_hor.setTypeface(sport_font);
									// ///

									if (game_txt.contains("Double") == true) {
										new_btn_p_follow1_hor.setText("FOLLOW");
										new_btn_p_follow2_hor.setText("FOLLOW");
									} else {
										if (MainActivity.playerAll
												.contains(p1_code) == true) {
											new_btn_p_follow1_hor
													.setText("UNFOLLOW");
										} else {
											new_btn_p_follow1_hor.setText("FOLLOW");
										}

										if (MainActivity.playerAll
												.contains(p2_code) == true) {
											new_btn_p_follow2_hor
													.setText("UNFOLLOW");
										} else {
											new_btn_p_follow2_hor.setText("FOLLOW");
										}
									}
									final String game_text_final = game_txt;

									new_btn_p_follow1_hor
											.setOnClickListener(new OnClickListener() {

												@Override
												public void onClick(View arg0) {

													final String[] btn_info = new_btn_p_follow1_hor
															.getTag().toString()
															.split(":");

													String btn_name = new_btn_p_follow1_hor
															.getText().toString();

													if (game_text_final
															.contains("Double") == true) {
														Log.w("suraj",
																"Show Dialog");
														final custom_follow_dialog dialog = new custom_follow_dialog(
																act_con, device_id,
																btn_info[0],
																btn_info[1],
																btn_info[4],
																btn_info[5],
																btn_info[6],
																btn_info[7],
																btn_info[8],
																btn_info[2],
																btn_info[3]);

														dialog.show();

														final Timer t = new Timer();
														t.schedule(new TimerTask() {
															public void run() {
																dialog.dismiss();
																t.cancel();
																// return ;
															}
														}, 15000);

													} else {

														if (btn_name
																.equalsIgnoreCase("FOLLOW")) {

															Log.d("suraj",
																	"player_code = "
																			+ btn_info[0]);

															AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

																@Override
																protected void onPostExecute(
																		Void result) {
																	super.onPostExecute(result);
																	pd.dismiss();
																	datadapter.close();
																}

																@Override
																protected void onPreExecute() {

																	pd = ProgressDialog
																			.show(act_con,
																					"",
																					"Following...",
																					true);
																	super.onPreExecute();
																}

																@Override
																protected Void doInBackground(
																		Void... params) {

																	// datadapter.close();
																	datadapter
																			.open();

																	long c = datadapter
																			.insert_follow_info(
																					btn_info[0],
																					btn_info[1],
																					btn_info[8],
																					btn_info[2],
																					btn_info[4],
																					btn_info[3],
																					"P");

																	String response = Utils
																			.getJSONString("http://sportizza.com/interface/ios_follow.php?dev_id="
																					+ device_id
																					+ "&iso_cd="
																					+ StartActivity
																							.GetCountryCode(act_con)
																					+ "&follow="
																					+ btn_info[0]
																					+ "&follow_cs=-1");

																	if (c != 0) {
																		Thread t = new Thread(
																				new Runnable() {
																					public void run() {

																						act_con.runOnUiThread(new Runnable() {
																							public void run() {
																								Toast.makeText(
																										act_con.getApplicationContext(),
																										"Added to I follow",
																										Toast.LENGTH_SHORT)
																										.show();
																								Log.d("suraj",
																										"follow success..");
																								new_btn_p_follow1_hor
																										.setText("UNFOLLOW");
																								MainActivity.playerAll
																										.add(btn_info[0]);

																								StartActivity.foll_count++;

																								SharedPreferences.Editor editor = StartActivity.follow_count
																										.edit();
																								editor.putInt(
																										"follow_count",
																										StartActivity.foll_count);
																								editor.commit();
																							}
																						});
																					}
																				});
																		t.start();

																	} else {
																		Toast.makeText(
																				act_con.getApplicationContext(),
																				"Error during follow",
																				Toast.LENGTH_SHORT)
																				.show();
																	}

																	// press1 =
																	// true;
																	datadapter
																			.close();

																	return null;
																}
															};
															wait.execute();
														}
													}

												}
											});

									new_btn_p_follow2_hor
											.setOnClickListener(new OnClickListener() {

												@Override
												public void onClick(View arg0) {

													final String[] btn_info = new_btn_p_follow2_hor
															.getTag().toString()
															.split(":");

													String btn_name = new_btn_p_follow1_hor
															.getText().toString();

													if (game_text_final
															.contains("Double") == true) {
														Log.w("suraj",
																"Show Dialog");
														final custom_follow_dialog dialog = new custom_follow_dialog(
																act_con, device_id,
																btn_info[0],
																btn_info[1],
																btn_info[4],
																btn_info[5],
																btn_info[6],
																btn_info[7],
																btn_info[8],
																btn_info[2],
																btn_info[3]);

														dialog.show();

														final Timer t = new Timer();
														t.schedule(new TimerTask() {
															public void run() {
																dialog.dismiss();
																t.cancel();
																// return ;
															}
														}, 15000);

													} else {

														if (btn_name
																.equalsIgnoreCase("FOLLOW")) {

															Log.d("suraj",
																	"player_code = "
																			+ btn_info[0]);

															AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

																@Override
																protected void onPostExecute(
																		Void result) {
																	super.onPostExecute(result);
																	pd.dismiss();
																	
																	datadapter.close();
																}

																@Override
																protected void onPreExecute() {

																	pd = ProgressDialog
																			.show(act_con,
																					"",
																					"Following...",
																					true);
																	super.onPreExecute();
																}

																@Override
																protected Void doInBackground(
																		Void... params) {

//																	datadapter
//																			.close();
																	datadapter
																			.open();

																	long c = datadapter
																			.insert_follow_info(
																					btn_info[0],
																					btn_info[1],
																					btn_info[8],
																					btn_info[2],
																					btn_info[4],
																					btn_info[3],
																					"P");

																	String response = Utils
																			.getJSONString("http://sportizza.com/interface/ios_follow.php?dev_id="
																					+ device_id
																					+ "&iso_cd="
																					+ StartActivity
																							.GetCountryCode(act_con)
																					+ "&follow="
																					+ btn_info[0]
																					+ "&follow_cs=-1");

																	if (c != 0) {
																		Thread t = new Thread(
																				new Runnable() {
																					public void run() {

																						act_con.runOnUiThread(new Runnable() {
																							public void run() {
																								Toast.makeText(
																										act_con.getApplicationContext(),
																										"Added to I follow",
																										Toast.LENGTH_SHORT)
																										.show();
																								Log.d("suraj",
																										"follow success..");
																								new_btn_p_follow2_hor
																										.setText("UNFOLLOW");
																								MainActivity.playerAll
																										.add(btn_info[0]);

																								StartActivity.foll_count++;

																								SharedPreferences.Editor editor = StartActivity.follow_count
																										.edit();
																								editor.putInt(
																										"follow_count",
																										StartActivity.foll_count);
																								editor.commit();
																							}
																						});
																					}
																				});
																		t.start();

																	} else {
																		Toast.makeText(
																				act_con.getApplicationContext(),
																				"Error during follow",
																				Toast.LENGTH_SHORT)
																				.show();
																	}

																	// press1 =
																	// true;
																	datadapter
																			.close();

																	return null;
																}
															};
															wait.execute();
														}
													}

												}
											});

									btn_ticket.setTypeface(sport_font);
									
									btn_ticket
											.setOnClickListener(new OnClickListener() {

												@Override
												public void onClick(View v) {
													try {
													if (!tick_url.equals("")
															|| tick_url != null
															|| tick_url.length() != 0) {
														
														Fb_dialog_box pdb = new Fb_dialog_box(con,tick_url);
														pdb.show();
														
													} else {

														Toast.makeText(
																con,
																"Ticket url not Available",
																Toast.LENGTH_LONG)
																.show();

													}
													} catch (Exception e) {

														Toast.makeText(
																con,
																"Check after some time",
																Toast.LENGTH_SHORT)
																.show();

													}
												}
											});

									final String game_text = game_txt;

									btn_cal_add.setTypeface(sport_font);
									
									btn_cal_add
											.setOnClickListener(new OnClickListener() {

												@SuppressLint("NewApi")
												@Override
												public void onClick(View v) {

													String date_str = day_date[2];

													Log.v("suraj", "DAte = "
															+ date_str);

													Long start_date_mili = null;

													String title = null;

													if (game_text
															.contains("Double") == true) {
														title = player_1
																+ " / "
																+ player_3
																+ " Vs "
																+ player_2
																+ " / "
																+ player_4
																+ " - "
																+ every_row_matchs[1];
													} else {
														title = player_1
																+ " Vs "
																+ player_2
																+ " - "
																+ every_row_matchs[1];
													}

													String Desc = "SPORTIZZA";

													SimpleDateFormat dateFormat11 = new SimpleDateFormat(
															"dd-MM-yyyy hh:mm a");

													Date date11 = null;

													try {
														date11 = dateFormat11
																.parse(date_str);
													} catch (ParseException e) {
														e.printStackTrace();
													}

													start_date_mili = date11
															.getTime();

													try {

														long begin = start_date_mili;
														long end = start_date_mili + 30 * 60 * 1000;// ending
																									// time
																									// in
																									// milliseconds
														String[] proj = new String[] {
																Instances._ID,
																Instances.BEGIN,
																Instances.END,
																Instances.EVENT_ID };

														Cursor cursor = Instances.query(
																act_con.getContentResolver(),
																proj, begin, end);

														cursor.moveToFirst();

														if (cursor.getCount() > 0) {

															String title_cal = cursor
																	.getString(cursor
																			.getColumnIndex("title"));

															if (title_cal
																	.equals(title)) {
																Log.i("suraj",
																		"Cursor = "
																				+ cursor.getString(cursor
																						.getColumnIndex("title")));

																Toast.makeText(
																		act_con,
																		"Already Added to Calendar..",
																		Toast.LENGTH_SHORT)
																		.show();
															} else {
																Log.i("suraj",
																		"Add to calendar = "
																				+ title);

																if (sport_type
																		.equalsIgnoreCase("N")) {
																	addToCalendar(
																			con,
																			title,
																			Desc,
																			start_date_mili,
																			start_date_mili + 30 * 60 * 1000);
																	Toast.makeText(
																			act_con,
																			"Added to Calender..",
																			Toast.LENGTH_SHORT)
																			.show();
																} else {
																	addToCalendar_team(
																			con,
																			every_row_matchs[1],
																			game_text,
																			title,
																			start_date_mili,
																			start_date_mili + 30 * 60 * 1000);
																}
															}
														} else {
															Log.i("suraj",
																	"Add to calendar = "
																			+ title);
															if (sport_type
																	.equalsIgnoreCase("N")) {
																addToCalendar(
																		con,
																		title,
																		Desc,
																		start_date_mili,
																		start_date_mili + 30 * 60 * 1000);
																Toast.makeText(
																		act_con,
																		"Added to Calender..",
																		Toast.LENGTH_SHORT)
																		.show();
															} else {
																addToCalendar_team(
																		con,
																		every_row_matchs[1],
																		game_text,
																		title,
																		start_date_mili,
																		start_date_mili + 30 * 60 * 1000);
																Toast.makeText(
																		act_con,
																		"Added to Calender..",
																		Toast.LENGTH_SHORT)
																		.show();
															}

														}
													} catch (Exception e) {
														e.printStackTrace();
													}

												}

												@SuppressWarnings("deprecation")
												@SuppressLint("NewApi")
												public void addToCalendar(
														Context ctx,
														final String title,
														final String desc,
														final long dtstart,
														final long dtend) {

													Uri eventsUri, reminderuri;

													if (Integer
															.parseInt(android.os.Build.VERSION.SDK) >= 14) {
														eventsUri = Uri
																.parse("content://com.android.calendar/events");
														reminderuri = Uri
																.parse("content://com.android.calendar/reminders");

														ContentValues event = new ContentValues();

														event.put(
																Events.CALENDAR_ID,
																1);
														event.put(Events.TITLE,
																title);
														event.put(
																Events.DESCRIPTION,
																desc);
														event.put(Events.DTSTART,
																dtstart);
														event.put(Events.DTEND,
																dtend);
														event.put(Events.STATUS, 1);
														event.put(
																Events.EVENT_COLOR,
																Color.RED);

														event.put(Events.HAS_ALARM,
																1);
														event.put(
																CalendarContract.Events.EVENT_TIMEZONE,
																TimeZone.getDefault()
																		.getID());

														// To Insert
														Log.v("suraj",
																"Event ="
																		+ TimeZone
																				.getDefault()
																				.getID());

														Uri uri = ctx
																.getContentResolver()
																.insert(CalendarContract.Events.CONTENT_URI,
																		event);

														long eventID = Long.parseLong(uri
																.getLastPathSegment());

														ContentValues reminders = new ContentValues();
														reminders.put(
																Reminders.EVENT_ID,
																eventID);
														reminders
																.put(Reminders.METHOD,
																		Reminders.METHOD_ALERT);
														reminders.put(
																Reminders.MINUTES,
																15);

														ctx.getContentResolver()
																.insert(CalendarContract.Reminders.CONTENT_URI,
																		reminders);

														Log.v("suraj", "Reminder ="
																+ reminders);

													} else if (Integer
															.parseInt(android.os.Build.VERSION.SDK) >= 8
															&& Integer
																	.parseInt(android.os.Build.VERSION.SDK) < 14) {

														eventsUri = Uri
																.parse("content://com.android.calendar/events");
														reminderuri = Uri
																.parse("content://com.android.calendar/reminders");
														ContentValues event = new ContentValues();

														event.put(
																Events.CALENDAR_ID,
																1);
														event.put(Events.TITLE,
																title);
														event.put(
																Events.DESCRIPTION,
																desc);
														event.put(Events.DTSTART,
																dtstart);
														event.put(Events.DTEND,
																dtend);
														event.put(Events.STATUS, 1);
														event.put(Events.HAS_ALARM,
																1);
														event.put(
																CalendarContract.Events.EVENT_TIMEZONE,
																TimeZone.getDefault()
																		.getID());

														Log.v("suraj",
																"Event ="
																		+ TimeZone
																				.getDefault()
																				.getID());

														Uri uri = ctx
																.getContentResolver()
																.insert(eventsUri,
																		event);

														long eventID = Long.parseLong(uri
																.getLastPathSegment());

														ContentValues reminders = new ContentValues();
														reminders.put(
																Reminders.EVENT_ID,
																eventID);
														reminders
																.put(Reminders.METHOD,
																		Reminders.METHOD_ALERT);
														reminders.put(
																Reminders.MINUTES,
																15);

														ctx.getContentResolver()
																.insert(reminderuri,
																		reminders);

														Log.v("suraj", "Reminder ="
																+ reminders);
													}
												}

												@SuppressWarnings("deprecation")
												@SuppressLint("NewApi")
												public void addToCalendar_team(
														Context ctx,
														final String title,
														final String desc,
														final String tit,
														final long dtstart,
														final long dtend) {

													Uri eventsUri, reminderuri;

													if (Integer
															.parseInt(android.os.Build.VERSION.SDK) >= 14) {
														eventsUri = Uri
																.parse("content://com.android.calendar/events");
														reminderuri = Uri
																.parse("content://com.android.calendar/reminders");
														ContentValues event = new ContentValues();

														event.put(
																Events.CALENDAR_ID,
																1);
														event.put(Events.TITLE, tit);
														event.put(
																Events.DESCRIPTION,
																"SPORTIZZA");
														event.put(Events.DTSTART,
																dtstart);
														event.put(Events.DTEND,
																dtend);
														event.put(Events.STATUS, 1);
														event.put(
																Events.EVENT_COLOR,
																Color.BLUE);
														event.put(Events.HAS_ALARM,
																1);
														event.put(
																CalendarContract.Events.EVENT_TIMEZONE,
																TimeZone.getDefault()
																		.getID());

														// To Insert
														Log.v("suraj",
																"Event ="
																		+ TimeZone
																				.getDefault()
																				.getID());

														Uri uri = ctx
																.getContentResolver()
																.insert(CalendarContract.Events.CONTENT_URI,
																		event);

														long eventID = Long.parseLong(uri
																.getLastPathSegment());

														ContentValues reminders = new ContentValues();
														reminders.put(
																Reminders.EVENT_ID,
																eventID);
														reminders
																.put(Reminders.METHOD,
																		Reminders.METHOD_ALERT);
														reminders.put(
																Reminders.MINUTES,
																15);

														ctx.getContentResolver()
																.insert(CalendarContract.Reminders.CONTENT_URI,
																		reminders);

														Log.v("suraj", "Reminder ="
																+ reminders);

													} else if (Integer
															.parseInt(android.os.Build.VERSION.SDK) >= 8
															&& Integer
																	.parseInt(android.os.Build.VERSION.SDK) < 14) {
														eventsUri = Uri
																.parse("content://com.android.calendar/events");
														reminderuri = Uri
																.parse("content://com.android.calendar/reminders");

														ContentValues event = new ContentValues();

														event.put(
																Events.CALENDAR_ID,
																1);
														event.put(Events.TITLE, tit);
														event.put(
																Events.DESCRIPTION,
																"SPORTIZZA");
														event.put(Events.DTSTART,
																dtstart);
														event.put(Events.DTEND,
																dtend);
														event.put(Events.STATUS, 1);
														event.put(Events.HAS_ALARM,
																1);
														event.put(
																CalendarContract.Events.EVENT_TIMEZONE,
																TimeZone.getDefault()
																		.getID());

														// To Insert
														Log.v("suraj",
																"Event ="
																		+ TimeZone
																				.getDefault()
																				.getID());

														Uri uri = ctx
																.getContentResolver()
																.insert(eventsUri,
																		event);

														long eventID = Long.parseLong(uri
																.getLastPathSegment());

														ContentValues reminders = new ContentValues();
														reminders.put(
																Reminders.EVENT_ID,
																eventID);
														reminders
																.put(Reminders.METHOD,
																		Reminders.METHOD_ALERT);
														reminders.put(
																Reminders.MINUTES,
																15);

														ctx.getContentResolver()
																.insert(reminderuri,
																		reminders);

														Log.v("suraj", "Reminder ="
																+ reminders);
													}
												}
											});

									// if (sport_type.equalsIgnoreCase("N")) {
									//
									// String game_txt1 = every_row_matchs[pos + 4];
									//
									// if (game_txt1.contains("Double") == true) {
									// new_btn_p_follow1_hor.setText("FOLLOW");
									// new_btn_p_follow2_hor.setText("FOLLOW");
									// } else {
									// Log.d("suraj", "playerAll = "
									// + MainActivity.playerAll);
									//
									// if (MainActivity.playerAll != null) {
									// String[] b1_tag = new_btn_p_follow1_hor
									// .getTag().toString()
									// .split(":");
									// String[] b2_tag = new_btn_p_follow2_hor
									// .getTag().toString()
									// .split(":");
									//
									// if (MainActivity.playerAll
									// .contains(b1_tag[0]) == true) {
									// new_btn_p_follow1_hor
									// .setText("UNFOLLOW");
									// } else {
									// new_btn_p_follow1_hor
									// .setText("FOLLOW");
									// }
									//
									// if (MainActivity.playerAll
									// .contains(b2_tag[0]) == true) {
									// new_btn_p_follow2_hor
									// .setText("UNFOLLOW");
									// } else {
									// new_btn_p_follow2_hor
									// .setText("FOLLOW");
									// }
									// }
									// }
									// } else {
									// if (MainActivity.playerAll != null) {
									// String[] b1_tag = new_btn_p_follow1_hor
									// .getTag().toString().split(":");
									// String[] b2_tag = new_btn_p_follow2_hor
									// .getTag().toString().split(":");
									//
									// if (MainActivity.playerAll
									// .contains(b1_tag[0]) == true) {
									// new_btn_p_follow1_hor
									// .setText("UNFOLLOW");
									// } else {
									// new_btn_p_follow1_hor
									// .setText("FOLLOW");
									// }
									//
									// if (MainActivity.playerAll
									// .contains(b2_tag[0]) == true) {
									// new_btn_p_follow2_hor
									// .setText("UNFOLLOW");
									// } else {
									// new_btn_p_follow2_hor
									// .setText("FOLLOW");
									// }
									// }
									// }

									// //////

									TextView ch1 = (TextView) additionView
											.findViewById(R.id.new_img_p_channel2_hor);

									if (chan1.equals("null")
											|| chan1.equals("NONE")
											|| chan1 == null) {
										ch1.setText("");
									} else {
										ch1.setText(chan1);
										ch1.setTypeface(sport_font);
									}

									TextView ch2 = (TextView) additionView
											.findViewById(R.id.new_img_p_channel1_hor);
									if (chan2.equals("null")
											|| chan2.equals("NONE")
											|| chan2 == null) {
										ch2.setText("");
									} else {
										ch2.setText(chan2);
										ch2.setTypeface(sport_font);
									}

									TextView ch3 = (TextView) additionView
											.findViewById(R.id.new_img_p_channel3_hor);

									Log.i("suraj",
											"Chan 3 == " + chan3.equals("null"));
									Log.v("suraj",
											"Chan 3 == " + chan3.equals(null));

									if (chan3.equals("NONE")
											|| chan3.equals("null")
											|| chan3 == null) {
										ch3.setText("");
									} else {
										ch3.setText(chan3);
										ch3.setTypeface(sport_font);
									}
									// Button new_btn_player_addcal_hor = (Button)
									// additionView
									// .findViewById(R.id.new_btn_player_addcal_hor);
									// Button ticket_player_hor = (Button)
									// additionView
									// .findViewById(R.id.ticket_player_hor);

									pos += 6;

									holder.horizontal_layout_upcoming
											.addView(linear);

								}

								Bitmap bi_result = null;

								try {
									bi_result = BitmapFactory.decodeStream(con
											.getResources()
											.getAssets()
											.open("sport_small/" + sport_code
													+ "_S.png"));
								} catch (IOException e1) {
									e1.printStackTrace();
									try {
										bi_result = BitmapFactory.decodeStream(con
												.getResources()
												.getAssets()
												.open("sport_small/GAM_S.png"));
									} catch (IOException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}
								}

								if (bi_result == null) {
									holder.txt_champ_name_upcoming
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_selected, 0, 0,
													0);

									holder.txt_champ_name_upcoming
											.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
								} else {
									Bitmap bitmap = Bitmap.createScaledBitmap(
											bi_result, 30, 30, true);

									Drawable tmpDraw = (Drawable) new BitmapDrawable(
											con.getResources(), bitmap);

									holder.txt_champ_name_upcoming
											.setCompoundDrawablesWithIntrinsicBounds(
													tmpDraw, null, null, null);
								}

								holder.txt_champ_name_upcoming
										.setText(" "+every_row_matchs[1]);
								holder.txt_champ_name_upcoming
								.setTypeface(sport_font);
								holder.txt_sport_name_upcoming
										.setText(every_row_matchs[2]);
								holder.txt_sport_name_upcoming.setTypeface(sport_font);
//							}
//	
//						});
//	
//					}
//				}).start();

			} else if (is_team.equals("A")) {

				Log.d("suraj_", "Suraj SHinde champ_details= " + champ_details);

//				new Thread(new Runnable() {
//	
//					@Override
//					public void run() {
//	
//						act_con.runOnUiThread(new Runnable() {
//	
//							@Override
//							public void run() {
								final String[] champ_data = champ_details
										.split(";");

								int pos = 4;

								final String sp_code = champ_data[3];

								// int champ_count=0 ;//=
								// new_follow_match.get(position).getnew_champ_count();
								
								holder.txt_champ_name_upcoming
								.setText(" "+champ_data[1]);
								holder.txt_champ_name_upcoming.setTypeface(sport_font);
								holder.txt_sport_name_upcoming
								.setText(champ_data[2]);
								holder.txt_champ_name_upcoming.setTypeface(sport_font);
						
								holder.horizontal_layout_upcoming.removeAllViews();

								int rc=0;
								
								if(row_count >=  10)
								{
									rc=10;
								}
								else
								{
									rc=row_count;
								}
								
								for (int j = 0; j < rc; j++) {
									View add_View = inflater.inflate(
											R.layout.new_hori_champ_row, null,
											false);

									final RelativeLayout linear = (RelativeLayout) add_View
											.findViewById(R.id.new_hori_champ_layout);

									LinearLayout linear_main = (LinearLayout) add_View
											.findViewById(R.id.linear_main);

//									RelativeLayout btn_rel = (RelativeLayout) add_View
//											.findViewById(R.id.relativeLayout21);
									
									RelativeLayout relativeLayout1 =(RelativeLayout) add_View.findViewById(R.id.relativeLayout1_hori);
									
//									btn_rel.setVisibility(View.VISIBLE);

									if (j == row_count - 1) {
										add_View.findViewById(R.id.gap_champ)
												.setVisibility(View.INVISIBLE);
									}

									LayoutParams lparams = new LayoutParams(
											LayoutParams.WRAP_CONTENT,
											LayoutParams.WRAP_CONTENT);

									String match_details = champ_data[pos];

									Log.d("suraj", "Suraj SHINDE Match_details=="
											+ match_details);

									pos++;

									final String[] match = match_details.split("!");

									TextView game_txt = (TextView) add_View
											.findViewById(R.id.new_text_game);

									game_txt.setText(match[1]);
									game_txt.setSelected(true);
									game_txt.setTypeface(sport_font);

									String channels = match[2];

									String[] ch = channels.split(",");

									String[] chan = ch[1].split(":");

									Log.w("suraj", "Channel = " + ch[1]);

									String channel1 = chan[0];
									String channel2 = chan[1];
									String channel3 = chan[2];

									final String[] ticket = match[0].split(",");
									
									Log.v("suraj", "game_txt==" + match.length);

									if(match.length > 9)
									{
										RelativeLayout.LayoutParams adaptLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
										
										relativeLayout1.setLayoutParams(adaptLayout);
									}
									
									for (int i = 0; i < match.length; i++) {

										if (match[i] != null) {
											if (match[i].contains("date")) {
												String[] champ_d = match[i]
														.split(",");
												com.sportizz.model.custom_marquee_text tv=new custom_marquee_text(act_con);
//												TextView tv = new TextView(act_con);
												tv.setTypeface(sport_font);
												tv.setLayoutParams(lparams);
												tv.setText(champ_d[1]);
												tv.setTypeface(sport_font);
												tv.setFocusable(true);
												tv.setFocusableInTouchMode(true);
												tv.setSelected(true);
												tv.setTextSize(11);
												tv.setSingleLine(true);
												tv.setTextColor(Color
														.parseColor("#FFCC11"));
												linear_main.addView(tv);
											} else if (match[i].contains("time")) {
												String[] champ_d = match[i]
														.split(",");
												com.sportizz.model.custom_marquee_text tv=new custom_marquee_text(act_con);
//												TextView tv = new TextView(act_con);
												lparams.setMargins(20, 0, 0, 0);
												tv.setTextSize(11);
												tv.setLayoutParams(lparams);
												tv.setText(champ_d[1]);
												tv.setFocusable(true);
												tv.setTextColor(Color.WHITE);
												tv.setFocusableInTouchMode(true);
												tv.setSingleLine(true);
												tv.setSelected(true);
												tv.setTypeface(sport_font);
												linear_main.addView(tv);
											}
										}
									}

									
									final Button ticket_btn= (Button) add_View.findViewById(R.id.ticket_champ_hor);
									
									ticket_btn.setTypeface(sport_font);
									
									ticket_btn
											.setOnClickListener(new OnClickListener() {

												@Override
												public void onClick(View arg0) {

													try {

														if (!ticket[0].equals("")
																|| ticket[0] != null
																|| ticket[0]
																		.length() != 0) {

															Fb_dialog_box pdb = new Fb_dialog_box(con,ticket[0]);
															pdb.show();

														} else {

															Toast.makeText(con,"Check after some time",Toast.LENGTH_LONG).show();

														}
													} catch (Exception e) {

														Toast.makeText(con,"Check after some time",Toast.LENGTH_SHORT)
																.show();

													}

												}
											});
									
									final Button btn_follow_champ = (Button) add_View
											.findViewById(R.id.new_btn_c_follow_hor);
									
									btn_follow_champ.setVisibility(View.VISIBLE);
									
									btn_follow_champ.setTag(champ_data[0] + ":"
											+ champ_data[1] + ":" + champ_data[3]
											+ ":" + champ_data[2]);
									btn_follow_champ.setTypeface(sport_font);

									if (MainActivity.playerAll
											.contains(champ_data[0]) == true) {
										btn_follow_champ.setText("UNFOLLOW");
									} else {
										btn_follow_champ.setText("FOLLOW");
									}

									btn_follow_champ
											.setOnClickListener(new OnClickListener() {

												@Override
												public void onClick(View arg0) {
													// TODO Auto-generated method
													// stub
													String btn_name = btn_follow_champ
															.getText().toString();

													final String[] f_data = btn_follow_champ
															.getTag().toString()
															.split(":");

													if (btn_name.equals("FOLLOW")) {
														AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

															@Override
															protected void onPostExecute(
																	Void result) {
																super.onPostExecute(result);
																pd.dismiss();
																datadapter.close();
															}

															@Override
															protected void onPreExecute() {

																pd = ProgressDialog
																		.show(act_con,
																				"",
																				"Following...",
																				true);
																super.onPreExecute();
															}

															@Override
															protected Void doInBackground(
																	Void... params) {
																try {

																	// holder.new_champ_txt.setTag(champ_data[0]);

																	Log.d("suraj",
																			"Team_id ="
																					+ f_data[0]);
																	String response1 = null;

																	datadapter
																			.open();
																	Long insert_c = datadapter
																			.insert_follow_info(
																					f_data[0],
																					f_data[1],
																					f_data[2],
																					f_data[3],
																					null,
																					"A",
																					"C");

																	response1 = Utils
																			.getJSONString("http://sportizza.com/interface/ios_follow.php?dev_id="
																					+ device_id
																					+ "&iso_cd="
																					+ StartActivity
																							.GetCountryCode(con)
																					+ "&follow=-1&follow_cs="
																					+ f_data[0]
																					+ "");

																	Log.w("suraj",
																			"insert_c = "
																					+ insert_c);
																	datadapter
																			.close();

																	if (insert_c != 0
																			|| response1 != null) {

																		Thread t = new Thread(
																				new Runnable() {
																					public void run() {

																						act_con.runOnUiThread(new Runnable() {
																							public void run() {

																								btn_follow_champ
																										.setText("UNFOLLOW");

																								MainActivity.playerAll
																										.add(f_data[0]);

																								Toast.makeText(
																										act_con.getApplicationContext(),
																										"Added to I follow",
																										Toast.LENGTH_SHORT)
																										.show();
																								// holder.progressBar_follow.setVisibility(View.INVISIBLE);

																								Log.d("suraj",
																										"follow success..");

																								StartActivity.foll_count++;
																								//
																								SharedPreferences.Editor editor = StartActivity.follow_count
																										.edit();
																								editor.putInt(
																										"follow_count",
																										StartActivity.foll_count);
																								editor.commit();
																							}
																						});
																					}
																				});
																		t.start();

																	} else {
																		Toast.makeText(
																				act_con.getApplicationContext(),
																				"Error during follow",
																				Toast.LENGTH_SHORT)
																				.show();
																	}

																	datadapter
																			.close();

																} catch (Exception e) {
																	e.printStackTrace();
																	Toast.makeText(
																			act_con.getApplicationContext(),
																			"Error in follow ..",
																			Toast.LENGTH_SHORT)
																			.show();

																	datadapter
																			.close();

																	// holder.progressBar_follow.setVisibility(View.INVISIBLE);
																}
																return null;
															}
														};
														wait.execute();

													}
												}
											});

									final Button btn_cal_champ = (Button) add_View
											.findViewById(R.id.new_btn_champ_addcal_hor);

									btn_cal_champ.setTag(match[3]);
									// String My_date_cal = match[3];
									btn_cal_champ.setTypeface(sport_font);
									
									btn_cal_champ
											.setOnClickListener(new OnClickListener() {

												@Override
												public void onClick(View arg0) {

													String date_str = (String) btn_cal_champ
															.getTag();

													Log.v("suraj", "DAte = "
															+ date_str);

													Long start_date_mili = null;

													String title = match[1] + " - "
															+ champ_data[1];

													SimpleDateFormat dateFormat11 = new SimpleDateFormat(
															"dd-MM-yyyy hh:mm a");

													Date date11 = null;

													try {
														date11 = dateFormat11
																.parse(date_str);
													} catch (ParseException e) {
														e.printStackTrace();
													}

													start_date_mili = date11
															.getTime();

													long begin = start_date_mili;
													long end = start_date_mili + 30 * 60 * 1000;// ending
																								// time

													try {

														String[] proj = new String[] {
																Instances._ID,
																Instances.BEGIN,
																Instances.END,
																Instances.EVENT_ID };

														Cursor cursor = Instances.query(
																con.getContentResolver(),
																proj, begin, end);

														cursor.moveToFirst();

														Log.v("suraj", "Cursor = "
																+ cursor);

														Log.v("suraj",
																"Cursor COUNT = "
																		+ cursor.getCount());

														if (cursor.getCount() > 0) {
															String title_cal = cursor
																	.getString(cursor
																			.getColumnIndex("title"));

															if (title_cal
																	.equals(title)) {
																Log.i("suraj",
																		"Cursor = "
																				+ cursor.getString(cursor
																						.getColumnIndex("title")));

																Toast.makeText(
																		con,
																		"Already Added to Calendar..",
																		Toast.LENGTH_SHORT)
																		.show();
															} else {
																Log.i("suraj",
																		"Setting_Act.check_cal.isChecked() = "
																				+ Setting_Act.check_cal
																						.isChecked());

																Log.i("suraj",
																		"Add to calendar = "
																				+ title);

																addToCalendar_champ(
																		con,
																		champ_data[1],
																		match[1],
																		title,
																		start_date_mili,
																		start_date_mili + 30 * 60 * 1000);
																Toast.makeText(
																		con,
																		"Added to Calendar..",
																		Toast.LENGTH_SHORT)
																		.show();

															}
														} else {

															Log.i("suraj",
																	"Add to calendar = "
																			+ title);

															addToCalendar_champ(
																	con,
																	champ_data[1],
																	match[1],
																	title,
																	start_date_mili,
																	start_date_mili + 30 * 60 * 1000);
															Toast.makeText(
																	con,
																	"Added to Calendar..",
																	Toast.LENGTH_SHORT)
																	.show();
														}
														// } else {
														// Toast.makeText(act_context,
														// "Access Calendar is off in setting",
														// Toast.LENGTH_SHORT).show();
														// }
													} catch (Exception e) {
														e.printStackTrace();

														addToCalendar_champ(
																con,
																champ_data[1],
																match[1],
																title,
																start_date_mili,
																start_date_mili + 30 * 60 * 1000);
														Toast.makeText(
																con,
																"Added to Calendar..",
																Toast.LENGTH_SHORT)
																.show();
													}

												}

												@SuppressWarnings("deprecation")
												@SuppressLint("NewApi")
												public void addToCalendar_champ(
														Context ctx,
														final String title,
														final String desc,
														final String tit,
														final long dtstart,
														final long dtend) {

													Uri eventsUri, reminderuri;

													if (Integer
															.parseInt(android.os.Build.VERSION.SDK) >= 14) {
														eventsUri = Uri
																.parse("content://com.android.calendar/events");
														reminderuri = Uri
																.parse("content://com.android.calendar/reminders");
														// //
														ContentValues event = new ContentValues();

														event.put(
																Events.CALENDAR_ID,
																1);
														event.put(Events.TITLE, tit);
														event.put(
																Events.DESCRIPTION,
																"SPORTIZZA");
														event.put(Events.DTSTART,
																dtstart);
														event.put(Events.DTEND,
																dtend);
														event.put(Events.STATUS, 1);
														event.put(
																Events.EVENT_COLOR,
																Color.GREEN);

														event.put(Events.HAS_ALARM,
																1);
														event.put(
																CalendarContract.Events.EVENT_TIMEZONE,
																TimeZone.getDefault()
																		.getID());

														// To Insert
														Log.v("suraj",
																"Event ="
																		+ TimeZone
																				.getDefault()
																				.getID());

														Uri uri = ctx
																.getContentResolver()
																.insert(CalendarContract.Events.CONTENT_URI,
																		event);

														long eventID = Long.parseLong(uri
																.getLastPathSegment());

														ContentValues reminders = new ContentValues();
														reminders.put(
																Reminders.EVENT_ID,
																eventID);
														reminders
																.put(Reminders.METHOD,
																		Reminders.METHOD_ALERT);
														reminders.put(
																Reminders.MINUTES,
																15);

														ctx.getContentResolver()
																.insert(CalendarContract.Reminders.CONTENT_URI,
																		reminders);

														Log.v("suraj", "Reminder ="
																+ reminders);

													} else if (Integer
															.parseInt(android.os.Build.VERSION.SDK) >= 8
															&& Integer
																	.parseInt(android.os.Build.VERSION.SDK) < 14) {
														//
														eventsUri = Uri
																.parse("content://com.android.calendar/events");
														reminderuri = Uri
																.parse("content://com.android.calendar/reminders");
														// //

														ContentValues event = new ContentValues();

														event.put(
																Events.CALENDAR_ID,
																1);
														event.put(Events.TITLE, tit);
														event.put(
																Events.DESCRIPTION,
																"SPORTIZZA");
														event.put(Events.DTSTART,
																dtstart);
														event.put(Events.DTEND,
																dtend);
														event.put(Events.STATUS, 1);
														event.put(Events.HAS_ALARM,
																1);
														event.put(
																CalendarContract.Events.EVENT_TIMEZONE,
																TimeZone.getDefault()
																		.getID());

														// To Insert
														Log.v("suraj", "Event ="
																+ event);

														Uri uri = ctx
																.getContentResolver()
																.insert(eventsUri,
																		event);

														long eventID = Long.parseLong(uri
																.getLastPathSegment());

														ContentValues reminders = new ContentValues();
														reminders.put(
																Reminders.EVENT_ID,
																eventID);
														reminders
																.put(Reminders.METHOD,
																		Reminders.METHOD_ALERT);
														reminders.put(
																Reminders.MINUTES,
																15);

														ctx.getContentResolver()
																.insert(reminderuri,
																		reminders);

														Log.v("suraj", "Reminder ="
																+ reminders);
													}

												}
											});

									TextView ch1 = (TextView) add_View
											.findViewById(R.id.new_img_c_channel2_hor);

									if (channel1.equals("null")
											|| channel1.equals("NONE")
											|| channel1 == null) {
										ch1.setText("");
									} else {
										ch1.setText(channel1);
										ch1.setTypeface(sport_font);
									}

									TextView ch2 = (TextView) add_View
											.findViewById(R.id.new_img_c_channel1_hor);
									if (channel2.equals("null")
											|| channel2.equals("NONE")
											|| channel2 == null) {
										ch2.setText("");
									} else {
										ch2.setText(channel2);
										ch2.setTypeface(sport_font);
									}

									TextView ch3 = (TextView) add_View
											.findViewById(R.id.new_img_c_channel3_hor);

									// Log.i("suraj","Chan 3 == "+
									// chan3.equals("null"));
									// Log.v("suraj","Chan 3 == "+
									// chan3.equals(null));

									if (channel3.equals("NONE")
											|| channel3.equals("null")
											|| channel3 == null) {
										ch3.setText("");
									} else {
										ch3.setText(channel3);
										ch3.setTypeface(sport_font);
									}

									// /////////

									final ImageView champ_img = (ImageView) add_View
											.findViewById(R.id.image_champ_hor);

									InputStream is1 = null;

									try {
										is1 = act_con
												.getResources()
												.getAssets()
												.open("new_sports/" + sp_code
														+ ".png");

										Bitmap res2 = BitmapFactory
												.decodeStream(is1);


										Bitmap output1 = Bitmap.createBitmap(
												res2.getWidth(), res2.getHeight(),
												Bitmap.Config.ARGB_8888);
										Canvas canvas1 = new Canvas(output1);

										Paint paint = new Paint();
										Rect rect = new Rect(0, 0, res2.getWidth(),
												res2.getHeight());
										RectF rectF = new RectF(rect);
										float roundPx1 = 8f;

										paint.setAntiAlias(true);
										canvas1.drawARGB(0, 0, 0, 0);
										paint.setColor(0xff424242);
										canvas1.drawRoundRect(rectF, roundPx1,
												roundPx1, paint);
										paint.setXfermode(new PorterDuffXfermode(
												Mode.SRC_IN));
										canvas1.drawBitmap(res2, rect, rect, paint);

										champ_img.setImageBitmap(output1);
										champ_img
												.setScaleType(ScaleType.FIT_CENTER);

										final String champ_img_url = ""
												+ StartActivity.get_img_location
												+ "phone/CS/"
												+ champ_data[0] + ".png";

										// new imageTask_champ(champ_img,
										// champ_data[3])
										// .execute(champ_img_url);

												int loader = getImgLoader(sp_code);

												imgLoader.DisplayImage(
														champ_img_url, loader,
														champ_img);

									} catch (Exception e) {
										e.printStackTrace();
										try{
										is1 = act_con
												.getResources()
												.getAssets()
												.open("new_sports/GAM.png");

										Bitmap res2 = BitmapFactory
												.decodeStream(is1);


										Bitmap output1 = Bitmap.createBitmap(
												res2.getWidth(), res2.getHeight(),
												Bitmap.Config.ARGB_8888);
										Canvas canvas1 = new Canvas(output1);

										Paint paint = new Paint();
										Rect rect = new Rect(0, 0, res2.getWidth(),
												res2.getHeight());
										RectF rectF = new RectF(rect);
										float roundPx1 = 8f;

										paint.setAntiAlias(true);
										canvas1.drawARGB(0, 0, 0, 0);
										paint.setColor(0xff424242);
										canvas1.drawRoundRect(rectF, roundPx1,
												roundPx1, paint);
										paint.setXfermode(new PorterDuffXfermode(
												Mode.SRC_IN));
										canvas1.drawBitmap(res2, rect, rect, paint);

										champ_img.setImageBitmap(output1);
										champ_img
												.setScaleType(ScaleType.FIT_CENTER);

										final String champ_img_url = ""
												+ StartActivity.get_img_location
												+ "phone/CS/"
												+ champ_data[0] + ".png";

										// new imageTask_champ(champ_img,
										// champ_data[3])
										// .execute(champ_img_url);

												int loader = getImgLoader(sp_code);

												imgLoader.DisplayImage(
														champ_img_url, loader,
														champ_img);
										}
										catch (Exception e1) {
										}
									}

									// /////////
									holder.horizontal_layout_upcoming
											.addView(linear);

								}

								Bitmap bi_result = null;

								try {
									bi_result = BitmapFactory.decodeStream(con
											.getResources()
											.getAssets()
											.open("sport_small/" + sp_code
													+ "_S.png"));
								} catch (IOException e1) {
									e1.printStackTrace();
									try {
										bi_result = BitmapFactory.decodeStream(con
												.getResources()
												.getAssets()
												.open("sport_small/GAM_S.png"));
									} catch (IOException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}
								}

								if (bi_result == null) {
									holder.txt_champ_name_upcoming
											.setCompoundDrawablesWithIntrinsicBounds(
													R.drawable.team_selected, 0, 0,
													0);

									holder.txt_champ_name_upcoming
											.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
								} else {
									Bitmap bitmap = Bitmap.createScaledBitmap(
											bi_result, 30, 30, true);

									Drawable tmpDraw = (Drawable) new BitmapDrawable(
											con.getResources(), bitmap);

									holder.txt_champ_name_upcoming
											.setCompoundDrawablesWithIntrinsicBounds(
													tmpDraw, null, null, null);
								}


//							}
//						});
//	
//					}
//				}).start();
				// return null;
				// }
				// };
				// wait.execute();

				
						}
//					}
//				});
//
//			}
//		}).start();

		return convertView;
	}

	static class ViewHolder {
		LinearLayout horizontal_layout_upcoming;
		TextView txt_champ_name_upcoming;
		TextView txt_sport_name_upcoming;
		LinearLayout new_layout_gap;
	}

	private class imageTask extends AsyncTask<String, Void, Bitmap> {
		ImageView imageView = null;

		String sp_code = null;

		imageTask(ImageView iv, String sport_code) {
			this.imageView = iv;
			this.sp_code = sport_code;
		}

		@Override
		protected Bitmap doInBackground(String... params) {
			try {
				return download_Image(params[0]);

			} catch (OutOfMemoryError e) {
				return null;
			}
		}

		@Override
		protected void onPostExecute(Bitmap result) {

			Bitmap output = null;
			Canvas canvas;
			float roundPx;
			if (result == null) {

				InputStream is = null;
				try {
					is = con.getResources().getAssets()
							.open("new_sports/" + sp_code + ".png");

					result = BitmapFactory.decodeStream(is);
				} catch (Exception e) {
					try {
						is = con.getResources().getAssets()
								.open("new_sports/GAM.png");
					result = BitmapFactory.decodeStream(is);
					} catch (IOException e1) {
					}
				}

				output = Bitmap.createBitmap(result.getWidth(),
						result.getHeight(), Bitmap.Config.ARGB_8888);
				canvas = new Canvas(output);

				Paint paint = new Paint();
				Rect rect = new Rect(0, 0, result.getWidth(),
						result.getHeight());
				RectF rectF = new RectF(rect);
				roundPx = 8f;

				paint.setAntiAlias(true);
				canvas.drawARGB(0, 0, 0, 0);
				paint.setColor(0xff424242);
				canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
				paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
				canvas.drawBitmap(result, rect, rect, paint);

				imageView.setImageBitmap(output);
				// imageView.setScaleType(ScaleType.FIT_CENTER);

			} else {

				output = Bitmap.createBitmap(result.getWidth(),
						result.getHeight(), Bitmap.Config.ARGB_8888);
				canvas = new Canvas(output);

				Paint paint = new Paint();
				Rect rect = new Rect(0, 0, result.getWidth(),
						result.getHeight());
				RectF rectF = new RectF(rect);
				roundPx = 8f;

				paint.setAntiAlias(true);
				canvas.drawARGB(0, 0, 0, 0);
				paint.setColor(0xff424242);
				canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
				paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
				canvas.drawBitmap(result, rect, rect, paint);

				imageView.setImageBitmap(output);
				// imageView.setScaleType(ScaleType.FIT_CENTER);
			}

			super.onPostExecute(result);
		}

		private Bitmap download_Image(String url) {
			// ---------------------------------------------------
			Bitmap bm = null;
			try {
				URL aURL = new URL(url);
				URLConnection conn = aURL.openConnection();
				conn.connect();
				InputStream is = conn.getInputStream();
				BufferedInputStream bis = new BufferedInputStream(is);
				bm = BitmapFactory.decodeStream(bis);
				bis.close();
				is.close();
			} catch (Exception e) {
				Log.e("Hub", "Error getting the image from server : ");

				InputStream iss = null;
				try {
					iss = con.getResources().getAssets()
							.open("new_sports/" + sp_code + ".png");
				} catch (IOException e1) {
					e1.printStackTrace();
					try {
						iss = con.getResources().getAssets()
								.open("new_sports/GAM.png");
					} catch (IOException e2) {
					}
				}
				return BitmapFactory.decodeStream(iss);

			}
			return bm;

		}

	}

	private class imageTask_champ extends AsyncTask<String, Void, Bitmap> {
		ImageView imageView = null;
		String sp_code = null;

		imageTask_champ(ImageView iv, String champ_data) {
			this.imageView = iv;
			this.sp_code = champ_data;
		}

		@Override
		protected Bitmap doInBackground(String... params) {
			try {
				return download_Image(params[0]);

			} catch (OutOfMemoryError e) {
				return null;
			}

		}

		@Override
		protected void onPostExecute(Bitmap result) {
			Bitmap output;
			Canvas canvas;
			float roundPx;

			if (result == null) {

				InputStream is = null;

				try {

					is = act_con.getResources().getAssets()
							.open("new_sports/" + sp_code + ".png");

					result = BitmapFactory.decodeStream(is);

				} catch (Exception e) {
					try {

						is = act_con.getResources().getAssets()
								.open("new_sports/GAM.png");

						result = BitmapFactory.decodeStream(is);

					} catch (Exception e1) {
					}
				}

				output = Bitmap.createBitmap(result.getWidth(),
						result.getHeight(), Bitmap.Config.ARGB_8888);
				canvas = new Canvas(output);

				Paint paint = new Paint();
				Rect rect = new Rect(0, 0, result.getWidth(),
						result.getHeight());
				RectF rectF = new RectF(rect);
				roundPx = 8f;

				paint.setAntiAlias(true);
				canvas.drawARGB(0, 0, 0, 0);
				paint.setColor(0xff424242);
				canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
				paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
				canvas.drawBitmap(result, rect, rect, paint);

				imageView.setImageBitmap(output);
				imageView.setScaleType(ScaleType.FIT_CENTER);

			} else {
				output = Bitmap.createBitmap(result.getWidth(),
						result.getHeight(), Bitmap.Config.ARGB_8888);
				canvas = new Canvas(output);

				Paint paint = new Paint();
				Rect rect = new Rect(0, 0, result.getWidth(),
						result.getHeight());
				RectF rectF = new RectF(rect);
				roundPx = 8f;

				paint.setAntiAlias(true);
				canvas.drawARGB(0, 0, 0, 0);
				paint.setColor(0xff424242);
				canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
				paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
				canvas.drawBitmap(result, rect, rect, paint);

				imageView.setImageBitmap(output);

			}
			super.onPostExecute(result);
		}

		private Bitmap download_Image(String url) {
			// ---------------------------------------------------
			Bitmap bm = null;
			try {
				URL aURL = new URL(url);
				URLConnection conn = aURL.openConnection();
				conn.connect();
				InputStream is = conn.getInputStream();
				BufferedInputStream bis = new BufferedInputStream(is);
				bm = BitmapFactory.decodeStream(bis);
				bis.close();
				is.close();
			} catch (Exception e) {
				Log.e("Hub", "Error getting the image from server : ");
				InputStream iss = null;
				try {
					iss = act_con.getResources().getAssets()
							.open("new_sports/" + sp_code + ".png");
				} catch (IOException e1) {
					e1.printStackTrace();
					try {
						iss = act_con.getResources().getAssets()
								.open("new_sports/GAM.png");
					} catch (IOException e2) {
						// TODO Auto-generated catch block
						e2.printStackTrace();
					}
				}
				return BitmapFactory.decodeStream(iss);
			}

			return bm;

		}

	}

	public int getImgLoader(String sport_code) {

		int loader = R.drawable.gam;

		if (sport_code.equalsIgnoreCase("AFT")) {
			loader = R.drawable.aft;
		}else if(sport_code.equalsIgnoreCase("TT"))
		{
			loader = R.drawable.tt;
		}else if(sport_code.equalsIgnoreCase("POL"))
		{
			loader = R.drawable.pol;
		}else if(sport_code.equalsIgnoreCase("SWI"))
		{
			loader = R.drawable.swi;
		}else if(sport_code.equalsIgnoreCase("UFC"))
		{
			loader = R.drawable.ufc;
		} else if (sport_code.equalsIgnoreCase("BAD")) {
			loader = R.drawable.bad;
		} else if (sport_code.equalsIgnoreCase("BB")) {
			loader = R.drawable.bb;
		} else if (sport_code.equalsIgnoreCase("CRI")) {
			loader = R.drawable.cri;
		} else if (sport_code.equalsIgnoreCase("F1")) {
			loader = R.drawable.f1;
		} else if (sport_code.equalsIgnoreCase("GAM")) {
			loader = R.drawable.gam;
		} else if (sport_code.equalsIgnoreCase("GOL")) {
			loader = R.drawable.gol;
		} else if (sport_code.equalsIgnoreCase("HOC")) {
			loader = R.drawable.hoc;
		} else if (sport_code.equalsIgnoreCase("ICE")) {
			loader = R.drawable.ice;
		} else if (sport_code.equalsIgnoreCase("IND")) {
			loader = R.drawable.ind;
		} else if (sport_code.equalsIgnoreCase("MGP")) {
			loader = R.drawable.mgp;
		} else if (sport_code.equalsIgnoreCase("NAS")) {
			loader = R.drawable.nas;
		} else if (sport_code.equalsIgnoreCase("OLY")) {
			loader = R.drawable.oly;
		} else if (sport_code.equalsIgnoreCase("RUG")) {
			loader = R.drawable.rug;
		} else if (sport_code.equalsIgnoreCase("SBK")) {
			loader = R.drawable.sbk;
		} else if (sport_code.equalsIgnoreCase("SOC")) {
			loader = R.drawable.soc;
		} else if (sport_code.equalsIgnoreCase("SPO")) {
			loader = R.drawable.spo;
		} else if (sport_code.equalsIgnoreCase("SQU")) {
			loader = R.drawable.squ;
		} else if (sport_code.equalsIgnoreCase("TEN")) {
			loader = R.drawable.ten;
		} else if (sport_code.equalsIgnoreCase("V8C")) {
			loader = R.drawable.v8c;
		} else if (sport_code.equalsIgnoreCase("WRC")) {
			loader = R.drawable.wrc;
		}
		else
		{
			loader = R.drawable.gam;
		}

		return loader;
	}

}
